package com.nervenets.web.controller.handler.user.wealth;

import com.nervenets.web.controller.handler.Handler;
import com.nervenets.web.controller.handler.common.IdTokenParams;
import com.nervenets.web.entity.MessageCode;
import com.nervenets.web.hibernate.domain.user.Bank;

import javax.servlet.http.HttpServletRequest;

public class UserBankDelHandler extends Handler<IdTokenParams> {
    @Override
    public String handle(IdTokenParams params, HttpServletRequest request) throws Exception {
        Bank bank = userDao.findById(params.getTargetId(), Bank.class);
        if (null == bank) return errorMessage(MessageCode.code_404, "银行记录不存在");
        userDao.delete(bank);
        return successMessage();
    }

    @Override
    public String result() throws Exception {
        return successMessage();
    }
}
